<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>ThinkYXC-CMS系统-添加权限</title>
    <link rel="stylesheet" type="text/css" href="../../layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="../../css/style.css">
    <style>
        .layui-btn+.layui-btn{
            margin-left: 10px !important;
        }
        .layui-btn.layuiadmin-btn-list{
            height: 38px;
            padding: 0px 18px;
            font-size: 14px;
            line-height: 38px;
        }
    </style>
</head>

<body>
    
       <div class="layui-card">
  <!--<div class="layui-card-header">卡片面板</div>-->
  <div class="layui-card-body">
     <div class="layui-tab">
  <ul class="layui-tab-title">
    <li class="layui-this">新增权限</li>
  </ul>
  <div class="layui-tab-content">
    <div class="layui-tab-item layui-show">
        <!--内容1-->
     <form class="layui-form forms" action="{:url('auth/authadd')}" method="post"  lay-filter="nei1s" id="nei1s">
          <div class="layui-form-item">
            <label class="layui-form-label"><span class="bitian">*</span>上一级规则</label>
            <div class="layui-input-block">
              <!--<input type="text" lay-verify="required" lay-reqtext="信息是必填项，岂能为空？" placeholder="请输入" autocomplete="off" class="layui-input">-->
              <select name="aid" lay-verify="required" lay-filter="aid">
                  <option value="0">顶级规则</option>
                 {foreach $auth as $i=>$value}
                    <option value="{$value.id}"><?php echo str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;├&nbsp;",$value["level"])?>{$value.title}</option>
                {/foreach}
              </select>
            </div>
          </div> 
         <div class="layui-form-item">
            <label class="layui-form-label"><span class="bitian">*</span>权限名称</label>
            <div class="layui-input-block">
              <input type="text" lay-verify="required" name="title" lay-reqtext="信息是必填项，岂能为空？" placeholder="请输入" autocomplete="off" class="layui-input" value="">
            </div>
          </div> 
          <div class="layui-form-item">
            <label class="layui-form-label"><span class="bitian">*</span>所属应用</label>
            <div class="layui-input-block">
              <input type="text" lay-verify="required" name="app" lay-reqtext="信息是必填项，岂能为空？" placeholder="如api，admin" autocomplete="off" class="layui-input" value="">
            </div>
          </div> 
           <div class="layui-form-item">
            <label class="layui-form-label"><span class="bitian">*</span>唯一标识</label>
            <div class="layui-input-block">
              <input type="text" lay-verify="required" name="name" lay-reqtext="信息是必填项，岂能为空？" placeholder="规则唯一英文标识,全小写" autocomplete="off" class="layui-input" value="">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label"><span class="bitian">*</span>权限分类</label>
            <div class="layui-input-block">
              <input type="text" lay-verify="required" name="type" lay-reqtext="信息是必填项，岂能为空？" placeholder="请加应用前缀,如admin_" autocomplete="off" class="layui-input" value="">
            </div>
          </div> 
             <div class="layui-form-item">
    <label class="layui-form-label">状态</label>
    <div class="layui-input-block">
      <input type="checkbox" name="status" lay-skin="switch" lay-text="显示|隐藏" checked lay-filter="status" id="status">
    </div>
  </div>

   <div class="layui-form-item">
    <div class="layui-input-block">
      <button type="submit" class="layui-btn" lay-submit="" lay-filter="nei1">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
     </form>   
        
    </div>
  </div>
</div>
  </div>
</div>
    
    
    
     <script type="text/javascript" src="../../layui/layui.all.js"></script>   
     <!--<script type="text/javascript" src="../../static/js/treeTable.js"></script> -->
     
<script>
var form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,$ = layui.jquery
  ,laydate = layui.laydate
   ,upload = layui.upload
   ,table = layui.table;
  var util = layui.util;
  
  
    //监听提交
  form.on('submit(nei1)', function(data){

    // console.log(JSON.stringify(data));
    var dast = form.val("nei1s");
    console.log(dast)
    
    
    $.ajax({
          url:"{:url('auth/authadds')}",
          data:{'data':dast},
          type:"Post",
          dataType:"json",
          success:function(data){
            console.log(data);
              layer.msg(data.msg);
              if(data.code == 1){
                  setTimeout(function(){
                  location.reload(); //删除成功后再刷新
                // layer.closeAll();
              },300) 
              }
             
              
          },
          error:function(data){
              $.messager.alert('错误',data.msg);
          }
      });
    // layer.alert(data.field.interest, {
    //   title: '最终的提交信息'
    // })
    return false;
  });
 
   </script>
</body>
</html>